unit OrderProcessor;

interface

uses
  System.SysUtils, Order, OrderEntry, OrderValidator;

type

  TEnumTest = (etA, etB, etC, etD);

  TEnumTestSet = set of TEnumTest;

  TOrderProcessor = class(TInterfacedObject)
  private
    FOrderValidator: TOrderValidator;
    FOrderEntry: TOrderEntry;
    FEnumTest: TEnumTest;
    FEnumTestSet: TEnumTestSet;
    FArrInteger: array of Integer;
    FArrString: array of string;
    FArrString2: array[0..3] of string;
  public
    constructor Create;
    function ProcessOrder(aOrder: TOrder): Boolean;
  end;

implementation

{ TOrderProcessor }


uses Spring.XE.Utils;
constructor TOrderProcessor.Create;
begin

end;

function TOrderProcessor.ProcessOrder(aOrder: TOrder): Boolean;
var
  OrderIsValid: Boolean;
  i: Integer;
begin
  Result := False;
  OrderIsValid := FOrderValidator.ValidateOrder(aOrder);
  if OrderIsValid then
  begin
    Result := FOrderEntry.EnterOrderIntoDatabase(aOrder);
  end;


  WriteLn('Order has been processed....' + IntToStr(Integer(FEnumTest)));
  Writeln('>>> etA in FEnumTestSet:' + BoolToStr(etA in FEnumTestSet, True));
  Writeln('>>> etB in FEnumTestSet:' + BoolToStr(etB in FEnumTestSet, True));
  Writeln('>>> etC in FEnumTestSet:' + BoolToStr(etC in FEnumTestSet, True));
  Writeln('>>> etD in FEnumTestSet:' + BoolToStr(etD in FEnumTestSet, True));

  for i := Low(FArrInteger) to High(FArrInteger) do
    Writeln('ArrInteger:' + IntToStr(FArrInteger[i]));

  for i := Low(FArrString) to High(FArrString) do
    Writeln('FArrString:' + FArrString[i]);

  for i := Low(FArrString2) to High(FArrString2) do
    Writeln('FArrString:' + FArrString2[i]);
end;

initialization
  TSpringXEUtils.TryRegisterClass(TOrderProcessor);

end.
